using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;using Maxleaf.EDI.Domain.K3;

namespace Maxleaf.EDI.DataAccess.K3
{
    public class ICPurBillMap : EntityTypeConfiguration<ICPurBill>
    {
        public ICPurBillMap()
        {
            // Primary Key
            this.HasKey(t => t.FInvoiceID);

            // Properties
            this.Property(t => t.FInvoiceID)
                .HasDatabaseGeneratedOption(DatabaseGeneratedOption.None);

            this.Property(t => t.FNumber)
                .HasMaxLength(80);

            this.Property(t => t.FExplanation)
                .HasMaxLength(255);

            this.Property(t => t.FOldBillNo)
                .HasMaxLength(80);

            this.Property(t => t.FFreeItem1)
                .HasMaxLength(20);

            this.Property(t => t.FFreeItem2)
                .HasMaxLength(20);

            // Table & Column Mappings
            this.ToTable("ICPurBill");
            this.Property(t => t.FInvoiceID).HasColumnName("FInvoiceID");
            this.Property(t => t.FNumber).HasColumnName("FNumber");
            this.Property(t => t.FType).HasColumnName("FType");
            this.Property(t => t.FDate).HasColumnName("FDate");
            this.Property(t => t.FYear).HasColumnName("FYear");
            this.Property(t => t.FPeriod).HasColumnName("FPeriod");
            this.Property(t => t.FExplanation).HasColumnName("FExplanation");
            this.Property(t => t.FCurrencyID).HasColumnName("FCurrencyID");
            this.Property(t => t.FExchangerate).HasColumnName("FExchangerate");
            this.Property(t => t.FItemClassID).HasColumnName("FItemClassID");
            this.Property(t => t.FVendor).HasColumnName("FVendor");
            this.Property(t => t.FDepartment).HasColumnName("FDepartment");
            this.Property(t => t.FEmployee).HasColumnName("FEmployee");
            this.Property(t => t.FTaxFor).HasColumnName("FTaxFor");
            this.Property(t => t.FTax).HasColumnName("FTax");
            this.Property(t => t.FTotalExpenseFor).HasColumnName("FTotalExpenseFor");
            this.Property(t => t.FTotalExpense).HasColumnName("FTotalExpense");
            this.Property(t => t.FTotalAmountFor).HasColumnName("FTotalAmountFor");
            this.Property(t => t.FTotalAmount).HasColumnName("FTotalAmount");
            this.Property(t => t.FTotalCostFor).HasColumnName("FTotalCostFor");
            this.Property(t => t.FTotalCost).HasColumnName("FTotalCost");
            this.Property(t => t.FOffsetTaxFor).HasColumnName("FOffsetTaxFor");
            this.Property(t => t.FOffsetTax).HasColumnName("FOffsetTax");
            this.Property(t => t.FOldBillNo).HasColumnName("FOldBillNo");
            this.Property(t => t.FRPDate).HasColumnName("FRPDate");
            this.Property(t => t.FInterestRate).HasColumnName("FInterestRate");
            this.Property(t => t.FPurType).HasColumnName("FPurType");
            this.Property(t => t.FPreparer).HasColumnName("FPreparer");
            this.Property(t => t.FChecker).HasColumnName("FChecker");
            this.Property(t => t.FStatus).HasColumnName("FStatus");
            this.Property(t => t.FVoucherID).HasColumnName("FVoucherID");
            this.Property(t => t.FGroupID).HasColumnName("FGroupID");
            this.Property(t => t.FDelete).HasColumnName("FDelete");
            this.Property(t => t.FImport).HasColumnName("FImport");
            this.Property(t => t.FOuterID).HasColumnName("FOuterID");
            this.Property(t => t.FFreeItem1).HasColumnName("FFreeItem1");
            this.Property(t => t.FFreeItem2).HasColumnName("FFreeItem2");
            this.Property(t => t.FFincDate).HasColumnName("FFincDate");
            this.Property(t => t.FTaskID).HasColumnName("FTaskID");
            this.Property(t => t.FResourceID).HasColumnName("FResourceID");

            // Relationships
            this.HasOptional(t => t.t_Currency)
                .WithMany(t => t.ICPurBills)
                .HasForeignKey(d => d.FCurrencyID);
            this.HasRequired(t => t.t_Item)
                .WithMany(t => t.ICPurBills)
                .HasForeignKey(d => d.FDepartment);
            this.HasRequired(t => t.t_Item1)
                .WithMany(t => t.ICPurBills1)
                .HasForeignKey(d => d.FEmployee);
            this.HasOptional(t => t.t_Item2)
                .WithMany(t => t.ICPurBills2)
                .HasForeignKey(d => d.FVendor);

        }
    }
}
